<script setup>
import { reactive,ref,onMounted } from 'vue';
import { useRouter } from 'vue-router'
import axios from 'axios'
const router = useRouter()
const data = reactive({
    account:localStorage.getItem('account')
})
const logout = () => {
    router.push('/login')
    localStorage.removeItem('token')
    localStorage.removeItem('account')
}
</script>

<template>
    <div class="home">
        <el-container>
            <el-header>
                <div class="top">
                    <div class="top-left">
                        <p>旗舰商城 (后台管理系统)</p>
                    </div>
                    <div class="top-right">
                        <div class="nickname">{{ data.account }}</div>
                        <el-button type="danger" @click="logout">退出登录</el-button>
                    </div>
                </div>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <el-menu active-text-color="#409efe" background-color="#fff" class="el-menu-vertical-demo"
                        default-active="2" text-color="#4c4b4e">

                        <el-sub-menu index="1">
                            <template #title>
                                <el-icon>
                                    <location />
                                </el-icon>
                                <span>仪表盘</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item @click="router.push('/dashboard')" :route="{path:'/dashboard'}" index="1-1">Dashboard</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                        <el-sub-menu index="2">
                            <template #title>
                                <span>业务管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item @click="router.push('/customerlist')" :route="{path:'/customerlist'}" index="2-1">会员管理</el-menu-item>
                                <el-menu-item @click="router.push('/orderlist')" :route="{path:'/orderlist'}" index="2-1">订单管理</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                        <el-sub-menu index="3">
                            <template #title>
                                <span>广告管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item @click="router.push('/advertlist')" :route="{path:'/advertlist'}" index="3-1">轮播图列表</el-menu-item>
                                <el-menu-item @click="router.push('/addadvert')" :route="{path:'/addadvert'}" index="3-2">添加轮播图</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                        <el-sub-menu index="4">
                            <template #title>
                                <span>商品管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item @click="router.push('/goodlist')" :route="{path:'/goodlist'}" index="4-1">商品列表</el-menu-item>
                                <el-menu-item @click="router.push('/addgood')" :route="{path:'/addgood'}" index="4-2">添加商品</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                        <el-sub-menu index="5">
                            <template #title>
                                <span>系统管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item @click="router.push('/modifyaccount')" :route="{path:'/modifyaccount'}" index="5-1">修改密码</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                    </el-menu>
                </el-aside>
                <el-main>
                    <router-view></router-view>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>
<style scoped>
.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    color: white;
}

.top-left {
    font-size: 22px;
    font-weight: 700;
}

.top-right {
    display: flex;
}
.nickname{
    line-height: 32px;
}

.top-right>div {
    margin-right: 10px;
}

.el-header {
    background-color: #28abec;

}


.el-main {

    height: 903px;
}
</style>